// 跨域调用方法
function fGetScript(sUrl, fSuc, fErr) {
    var oScript = document.createElement("script");
    oScript.setAttribute("type", "text/javascript");
    oScript.setAttribute("src", sUrl);
    try {
        oScript.setAttribute("defer", "defer");
    } catch (e) {}
    window.document.body.appendChild(oScript);
    oScript.onload = oScript.onreadystatechange = function() {
        if (!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete') {
            fSuc && fSuc();
        }
    };
    oScript.onerror = function() {
        fErr && fErr();
    };
}

// Base64编码
function fBase64Encode(str) {
    var utf8str = CryptoJS.enc.Utf8.parse(str);
    return CryptoJS.enc.Base64.stringify(utf8str);
}

// SHA1哈希
function fSHA1(str) {
    return CryptoJS.SHA1(str).toString();
}

// MD5加密
function fMD5(str) {
    return CryptoJS.MD5(str).toString();
}

// RSA
function RSA() {
    //setMaxDigits()的参数值根据选用的RSA的Key大小不同
    //1024位的Key，应该设置setMaxDigits(130)；如果是2048位的则应该设置为260
    setMaxDigits(130);
    this.key = null;
}

// Set the public key fields N and e from hex strings
RSA.prototype.setPublic = function(N, E) {
    if (N != null && E != null && N.length > 0 && E.length > 0) {
        this.key = new RSAKeyPair(E,"",N);//RSAKeyPair的三个参数：加密指数,解密参数,加密系数
    } else {
        alert("Invalid RSA public key");
    }
};

// Return the PKCS#1 RSA encryption of "text" as an even-length hex string
RSA.prototype.encrypt = function(text) {
    return encryptedString(this.key, text);
};

// 调用服务端方法
function fCall() {

}

// a javascript function framework
var jn = {};

jn.config = function() {

};

jn.call = function() {
    
};
